		var temp=0;

		var cur =-2;
		var pre =-1;
		var pause = 0;

		var second = 30;

		var cs = 30;

		var total = 0 ;
		
		
		var url = vision+"?g=home&m=shake&a=canrun";
		//alert(url);
		
		var dat = {
			step:step
			
		};
		$.post(url,dat,function(data)
		{
					if(data=="error")
					{
						
						setTimeout("window.location.href='"+vision+"?g=home&m=shake&a=result'",1000);
						
						
					}
					else
						{
						
						if(data!=step)
							{
							window.location.href=vision+'?g=home&m=shake&a=game';
							}
						
							if(step==1)
								{
									$msg = "GTX 950";
								}
							else if(step==2)
								{
									$msg = "MFAA";
								}
							else if(step==3)
							{
								$msg = "G-SYNC";
							}
							else if(step==4)
							{
								$msg = "DSR";
							}
							else if(step==5)
							{
								$msg = "DirectX 12";
							}
							else if(step==6)
							{
								$msg = "MOBA";
							}
							else if(step==7)
							{
								$msg = "Hair Works";
							}
							else if(step==8)
							{
								$msg = "3倍GTX650";
							}
							
							$msg = "请在30秒内找出匹对的2个"+$msg+"卡片";
							
							showMsg($msg);
						}
		},'text');
		
		
		
		function startGame()
		{
			setInterval("countSecond()",1000);
		}
		
		function nextGame(score,step)
		{
						var url = vision+"?g=home&m=shake&a=submitScore";
							
							var dat = {
								score:score,
								step:step
								
							};
							$.post(url,dat,function(data)
							{
//									if(step==8)
//									{
//										showMsg("挑战关卡成功，用时"+(30-cs)+"秒，获得"+data+"积分。");
//										setTimeout("window.location.href='/index.php?g=home&m=shake&a=result'",1000);
//									}
//									else
//									{
//									}
									showMsg("挑战关卡成功，用时"+(30-cs)+"秒，获得"+data+"积分。");
									setTimeout("window.location.href='"+vision+"?g=home&m=shake&a=msg'",1000);
									
							},'text');
							
							
		}
		
		function shakeDefault()
		{

			if((cur==r1&&pre==r2) || (cur==r2&&pre==r1))
			{
				total = 30 - cs;
//				alert("bingo,用时"+total+"秒");
				
				nextGame(total,step);
				return;
				
			}

			var aLi = $('#brand .bd-box li');
				var aImg =  $('img.down');
				var aSpan = $('img.up');

			aLi.each(function(index){

				aSpan.eq(index).stop();
						aImg.eq(index).stop();
						aSpan.eq(index).css({zIndex:1}).animate({
							top:37,
							height:0
						},60,'',function(){
							
							$(this).hide();
							aImg.eq(index).show().css({zIndex:2}).animate({
								top:0,
								height:60
							},60)
						})
			});


			
			 temp=0;

			 cur =-2;
			 pre =-1;
			 pause = 0;
		}

		
		

		function countSecond()
		{
			if(cs<0)
				{
				return;
				}
			if(cs==0)
			{
				var url = vision+"?g=home&m=shake&a=endGame";
				
				cs--;
				
				$.post(url,"",function(data)
				{
					showMsg("时间到，游戏结束。")
					setTimeout("window.location.href='"+vision+"?g=home&m=shake&a=result'",3000);
						
						
				},'text');

				return;
			}
			if(cs>0 && total ==0)
			{
				cs--;
			}
			
			var pw = cs*100/second;
			pw = pw+"%";
			
			
			$(".process-cover").css({width:pw});
			if(cs<10)
			{
				cs = "0"+cs;
			}
			$(".process-circle").html(cs);
			

		}
		
			
		function showMsg(msg)
		{
			$("#msg").text(msg);
						$('div#alert2').show();
						document.getElementById('mcover').style.display='block';
		}
		
		function showMsg2(msg)
		{
			$("#msg").text(msg);
						$('div#alert2').show();
						//document.getElementById('mcover').style.display='block';
		}
			
		
			$(function(){
				var aLi = $('#brand .bd-box li');
				var aImg =  $('img.down');
				var aSpan = $('img.up');
				
				$('a.alert-btn').click(function (e) {
					$('div.alert').hide();
				});
				
				
				
				aLi.each(function(index){
					$(this).click(function(){
						
						if(temp==0)
						{
							cur = index;
							
						}
						else
						{
							
							pre = index;
						}

						
						



						if(cur!=pre && pause ==0)
						{
							temp ++;
							aSpan.eq(index).stop();
							aImg.eq(index).stop();
							aImg.eq(index).css({zIndex:1}).animate({
								top:37,
								height:0
							},60,'',function(){
								
								$(this).hide();
								aSpan.eq(index).show().css({zIndex:2}).animate({
									top:0,
									height:60
								},60);

							});
						}
						
						if(temp>1 && pause ==0)
						{
							pause = 1;
							setTimeout("shakeDefault()",600);
							
						}

					}
						)
					})

				
				//countSecond();

				})
			